﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Reflection;

namespace QL_Truong_Hoc
{
    public partial class frmChonKhungDaoTao : DevExpress.XtraEditors.XtraForm
    {
        public bool Selected { get; set; }
        public int KhungDaoTaoID { get; set; }
        public int TrinhDoDaoTao { get; set; }
        public int Khoa { get; set; }
        public int Khoas { get; set; }
        public int Nghe { get; set; }

        public frmChonKhungDaoTao()
        {
            InitializeComponent();
        }

        private void frmChonKhungDaoTao_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'qLTHDataSet.mNghe' table. You can move, or remove it, as needed.
            this.mNgheTableAdapter.Fill(this.qLTHDataSet.mNghe);
            // TODO: This line of code loads data into the 'qLTHDataSet.mKhoaHoc' table. You can move, or remove it, as needed.
            this.mKhoaHocTableAdapter.Fill(this.qLTHDataSet.mKhoaHoc);
            // TODO: This line of code loads data into the 'qLTHDataSet.mKhoa' table. You can move, or remove it, as needed.
            this.mKhoaTableAdapter.Fill(this.qLTHDataSet.mKhoa);
            // TODO: This line of code loads data into the 'qLTHDataSet.mTrinhDoDaoTao' table. You can move, or remove it, as needed.
            this.mTrinhDoDaoTaoTableAdapter.Fill(this.qLTHDataSet.mTrinhDoDaoTao);
            // TODO: This line of code loads data into the 'qLTHDataSet.mKhungDaoTao' table. You can move, or remove it, as needed.
            this.mKhungDaoTaoTableAdapter.Fill(this.qLTHDataSet.mKhungDaoTao);

            this.Selected = false;
        }

        private void btnChoose_Click(object sender, EventArgs e)
        {
            try
            {
                //lấy dữ liệu
                this.KhungDaoTaoID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colKDT_ID));

                if (this.KhungDaoTaoID <= 0)
                {
                    clsCommon.fncMsgInfo("Hãy chọn một nghề.");
                    dgvKhung.Focus();
                    return;
                }

                this.KhungDaoTaoID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colKDT_ID));
                this.TrinhDoDaoTao = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colTD_ID));
                this.Khoa = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colKH_ID));
                this.Khoas = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colKHS_ID));
                this.Nghe = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colNG_ID));
                this.Selected = true;

                this.Close();
            }
            catch (Exception ex) { clsCommon.fncMsgError(MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, ex.Message); }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            try
            {               
                this.Close();
            }
            catch (Exception ex) { clsCommon.fncMsgError(MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, ex.Message); }
        }
    }
}